<template>
  <div>
    {{num}}
    <van-button @click="add">点我</van-button>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'home',
  data () {
    return {
      initNum: 1
    }
  },
  computed: {
    ...mapState({
      num: state => state.event.num
    })
  },
  methods: {
    add () {
      let that = this
      that.$store.commit('ADD_NUM', that.initNum++)
    }
  }
}

</script>

<style lang="scss" scoped>
  div {
    font-size: 28px;
    color: yellowgreen;
  }

</style>
